From: Jo-Philipp Wich Date: Thu, 9 Dec 2021 15:24:31 +0000 (+0100) Subject: luci-app-firewall: CBIProtocolSelect: properly handle unrecognized protos X-Git-Url: http://git.openwrt.org/%22https:/collectd.org//%22http:/www.crowdsec.net/%22/%22https:/collectd.org/%22http:/www.crowdsec.net/%22?a=commitdiff_plain;h=161880046f0773c394c9a3e93171a1a595735c79;p=project%2Fluci.git luci-app-firewall: CBIProtocolSelect: properly handle unrecognized protos Prevent incorrectly replacing unrecognized protocol numbers with -1. Fixes: #5587 Signed-off-by: Jo-Philipp Wich (cherry picked from commit 43818163155d5ce49414a8e54f5746a85606ba03) --- diff --git a/applications/luci-app-firewall/htdocs/luci-static/resources/tools/firewall.js b/applications/luci-app-firewall/htdocs/luci-static/resources/tools/firewall.js index 3f6a309033..03e505e89d 100644 --- a/applications/luci-app-firewall/htdocs/luci-static/resources/tools/firewall.js +++ b/applications/luci-app-firewall/htdocs/luci-static/resources/tools/firewall.js @@ -590,8 +590,7 @@ return baseclass.extend({ }); widget.createChoiceElement = function(sb, value) { - var m = value.match(/^(0x[0-9a-f]{1,2}|[0-9]{1,3})$/), - p = lookupProto(lookupProto(m ? +m[1] : value)[0]); + var p = lookupProto(value); return ui.Dropdown.prototype.createChoiceElement.call(this, sb, p[2], p[1]); }; @@ -601,9 +600,11 @@ return baseclass.extend({ var m = value.match(/^(0x[0-9a-f]{1,2}|[0-9]{1,3})$/), p = lookupProto(m ? +m[1] : value); - return (p[0] > -1) ? p[2] : value; + return (p[0] > -1) ? p[2] : p[1]; }); + values.sort(); + return ui.Dropdown.prototype.createItems.call(this, sb, values.join(' ')); };